home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr05 / att33all.zip / SETTIME.FRM < prev    next >
Text File  |  1995-01-31  |  23KB  |  875 lines

  1. VERSION 2.00
  2. Begin Form SetTimeForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Set Time"
  6.    ClientHeight    =   1305
  7.    ClientLeft      =   5100
  8.    ClientTop       =   3405
  9.    ClientWidth     =   3645
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   1740
  13.    Left            =   5025
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   1305
  18.    ScaleWidth      =   3645
  19.    Top             =   3045
  20.    Width           =   3795
  21.    Begin CommandButton Command1 
  22.       Cancel          =   -1  'True
  23.       Caption         =   "Check Now"
  24.       Height          =   360
  25.       Index           =   2
  26.       Left            =   2268
  27.       TabIndex        =   23
  28.       TabStop         =   0   'False
  29.       Top             =   2640
  30.       Width           =   1155
  31.    End
  32.    Begin TextBox Text2 
  33.       BackColor       =   &H00C0C0C0&
  34.       BorderStyle     =   0  'None
  35.       Height          =   192
  36.       Left            =   240
  37.       MultiLine       =   -1  'True
  38.       TabIndex        =   27
  39.       TabStop         =   0   'False
  40.       Text            =   "300"
  41.       Top             =   2760
  42.       Width           =   350
  43.    End
  44.    Begin SSFrame Frame3D1 
  45.       Caption         =   "Time Server Address"
  46.       ForeColor       =   &H00000000&
  47.       Height          =   624
  48.       Index           =   2
  49.       Left            =   240
  50.       TabIndex        =   22
  51.       Top             =   1800
  52.       Width           =   3132
  53.       Begin TextBox Text1 
  54.          BackColor       =   &H00C0C0C0&
  55.          BorderStyle     =   0  'None
  56.          Height          =   252
  57.          Left            =   120
  58.          TabIndex        =   25
  59.          TabStop         =   0   'False
  60.          Text            =   "panix.com"
  61.          Top             =   300
  62.          Width           =   2844
  63.       End
  64.    End
  65.    Begin SSCheck Check3D1 
  66.       Caption         =   "Use Time Server"
  67.       Height          =   312
  68.       Left            =   240
  69.       TabIndex        =   21
  70.       TabStop         =   0   'False
  71.       Top             =   1440
  72.       Width           =   1692
  73.    End
  74.    Begin SSCommand Command3D1 
  75.       Height          =   465
  76.       Left            =   165
  77.       Picture         =   SETTIME.FRX:0000
  78.       TabIndex        =   18
  79.       Top             =   720
  80.       Width           =   540
  81.    End
  82.    Begin CommandButton Command1 
  83.       Caption         =   "Cancel"
  84.       Height          =   360
  85.       Index           =   1
  86.       Left            =   2265
  87.       TabIndex        =   20
  88.       Top             =   765
  89.       Width           =   1155
  90.    End
  91.    Begin CommandButton Command1 
  92.       Caption         =   "Set"
  93.       Default         =   -1  'True
  94.       Height          =   360
  95.       Index           =   0
  96.       Left            =   885
  97.       TabIndex        =   19
  98.       Top             =   765
  99.       Width           =   1155
  100.    End
  101.    Begin PictureBox SpinButton 
  102.       AutoSize        =   -1  'True
  103.       BackColor       =   &H00C0C0C0&
  104.       Height          =   360
  105.       Index           =   1
  106.       Left            =   3255
  107.       ScaleHeight     =   330
  108.       ScaleWidth      =   135
  109.       TabIndex        =   17
  110.       TabStop         =   0   'False
  111.       Top             =   240
  112.       Width           =   165
  113.    End
  114.    Begin SSFrame Frame3D1 
  115.       ForeColor       =   &H00000000&
  116.       Height          =   444
  117.       Index           =   1
  118.       Left            =   1830
  119.       TabIndex        =   11
  120.       Top             =   156
  121.       Width           =   1395
  122.       Begin TextBox tYear 
  123.          BackColor       =   &H00C0C0C0&
  124.          BorderStyle     =   0  'None
  125.          Height          =   225
  126.          Left            =   780
  127.          MaxLength       =   4
  128.          TabIndex        =   14
  129.          Tag             =   "y"
  130.          Text            =   "1955"
  131.          Top             =   150
  132.          Width           =   480
  133.       End
  134.       Begin TextBox tDay 
  135.          BackColor       =   &H00C0C0C0&
  136.          BorderStyle     =   0  'None
  137.          Height          =   225
  138.          Left            =   450
  139.          MaxLength       =   2
  140.          TabIndex        =   13
  141.          Tag             =   "d"
  142.          Text            =   "17"
  143.          Top             =   150
  144.          Width           =   240
  145.       End
  146.       Begin TextBox tMonth 
  147.          Alignment       =   1  'Right Justify
  148.          BackColor       =   &H00C0C0C0&
  149.          BorderStyle     =   0  'None
  150.          Height          =   225
  151.          Left            =   120
  152.          MaxLength       =   2
  153.          TabIndex        =   12
  154.          Tag             =   "n"
  155.          Text            =   "09"
  156.          Top             =   150
  157.          Width           =   240
  158.       End
  159.       Begin Label Label1 
  160.          Alignment       =   2  'Center
  161.          BackColor       =   &H00C0C0C0&
  162.          Caption         =   "/"
  163.          Height          =   225
  164.          Index           =   3
  165.          Left            =   690
  166.          TabIndex        =   16
  167.          Top             =   150
  168.          Width           =   105
  169.       End
  170.       Begin Label Label1 
  171.          Alignment       =   2  'Center
  172.          BackColor       =   &H00C0C0C0&
  173.          Caption         =   "/"
  174.          Height          =   225
  175.          Index           =   2
  176.          Left            =   345
  177.          TabIndex        =   15
  178.          Top             =   150
  179.          Width           =   105
  180.       End
  181.    End
  182.    Begin PictureBox SpinButton 
  183.       AutoSize        =   -1  'True
  184.       BackColor       =   &H00C0C0C0&
  185.       Height          =   360
  186.       Index           =   0
  187.       Left            =   1590
  188.       ScaleHeight     =   330
  189.       ScaleWidth      =   135
  190.       TabIndex        =   7
  191.       TabStop         =   0   'False
  192.       Top             =   240
  193.       Width           =   165
  194.    End
  195.    Begin PictureBox N 
  196.       AutoSize        =   -1  'True
  197.       Height          =   360
  198.       Left            =   2736
  199.       Picture         =   SETTIME.FRX:016A
  200.       ScaleHeight     =   330
  201.       ScaleWidth      =   135
  202.       TabIndex        =   6
  203.       TabStop         =   0   'False
  204.       Top             =   3432
  205.       Visible         =   0   'False
  206.       Width           =   165
  207.    End
  208.    Begin PictureBox U 
  209.       AutoSize        =   -1  'True
  210.       Height          =   360
  211.       Left            =   2940
  212.       Picture         =   SETTIME.FRX:0294
  213.       ScaleHeight     =   330
  214.       ScaleWidth      =   135
  215.       TabIndex        =   5
  216.       TabStop         =   0   'False
  217.       Top             =   3420
  218.       Visible         =   0   'False
  219.       Width           =   165
  220.    End
  221.    Begin PictureBox D 
  222.       AutoSize        =   -1  'True
  223.       Height          =   360
  224.       Left            =   3168
  225.       Picture         =   SETTIME.FRX:03BE
  226.       ScaleHeight     =   330
  227.       ScaleWidth      =   135
  228.       TabIndex        =   0
  229.       TabStop         =   0   'False
  230.       Top             =   3420
  231.       Visible         =   0   'False
  232.       Width           =   165
  233.    End
  234.    Begin SSFrame Frame3D1 
  235.       ForeColor       =   &H00000000&
  236.       Height          =   444
  237.       Index           =   0
  238.       Left            =   168
  239.       TabIndex        =   8
  240.       Top             =   156
  241.       Width           =   1392
  242.       Begin TextBox tHour 
  243.          Alignment       =   1  'Right Justify
  244.          BackColor       =   &H00C0C0C0&
  245.          BorderStyle     =   0  'None
  246.          Height          =   225
  247.          Left            =   120
  248.          MaxLength       =   2
  249.          MultiLine       =   -1  'True
  250.          TabIndex        =   1
  251.          Tag             =   "h"
  252.          Text            =   "12"
  253.          Top             =   150
  254.          Width           =   240
  255.       End
  256.       Begin TextBox tMinute 
  257.          BackColor       =   &H00C0C0C0&
  258.          BorderStyle     =   0  'None
  259.          Height          =   225
  260.          Left            =   456
  261.          MaxLength       =   2
  262.          TabIndex        =   2
  263.          Tag             =   "m"
  264.          Text            =   "00"
  265.          Top             =   150
  266.          Width           =   240
  267.       End
  268.       Begin TextBox tAMPM 
  269.          BackColor       =   &H00C0C0C0&
  270.          BorderStyle     =   0  'None
  271.          Height          =   225
  272.          Left            =   1020
  273.          TabIndex        =   4
  274.          Tag             =   "a"
  275.          Text            =   "am"
  276.          Top             =   150
  277.          Width           =   285
  278.       End
  279.       Begin TextBox tSecond 
  280.          BackColor       =   &H00C0C0C0&
  281.          BorderStyle     =   0  'None
  282.          Height          =   225
  283.          Left            =   780
  284.          MaxLength       =   2
  285.          TabIndex        =   3
  286.          Tag             =   "s"
  287.          Text            =   "00"
  288.          Top             =   150
  289.          Width           =   240
  290.       End
  291.       Begin Label Label1 
  292.          Alignment       =   2  'Center
  293.          BackColor       =   &H00C0C0C0&
  294.          Caption         =   ":"
  295.          Height          =   225
  296.          Index           =   0
  297.          Left            =   345
  298.          TabIndex        =   10
  299.          Top             =   150
  300.          Width           =   105
  301.       End
  302.       Begin Label Label1 
  303.          Alignment       =   2  'Center
  304.          BackColor       =   &H00C0C0C0&
  305.          Caption         =   ":"
  306.          Height          =   225
  307.          Index           =   1
  308.          Left            =   675
  309.          TabIndex        =   9
  310.          Top             =   150
  311.          Width           =   105
  312.       End
  313.    End
  314.    Begin Label Label2 
  315.       BackStyle       =   0  'Transparent
  316.       Caption         =   "minutes."
  317.       ForeColor       =   &H00000000&
  318.       Height          =   252
  319.       Index           =   1
  320.       Left            =   600
  321.       TabIndex        =   24
  322.       Top             =   2760
  323.       Width           =   792
  324.    End
  325.    Begin Label Label2 
  326.       BackStyle       =   0  'Transparent
  327.       Caption         =   "Check every"
  328.       ForeColor       =   &H00000000&
  329.       Height          =   252
  330.       Index           =   0
  331.       Left            =   240
  332.       TabIndex        =   26
  333.       Top             =   2580
  334.       Width           =   1128
  335.    End
  336.    Begin Line Line1 
  337.       BorderColor     =   &H00FFFFFF&
  338.       Index           =   1
  339.       X1              =   252
  340.       X2              =   3372
  341.       Y1              =   1332
  342.       Y2              =   1332
  343.    End
  344.    Begin Line Line1 
  345.       BorderColor     =   &H00808080&
  346.       Index           =   0
  347.       X1              =   240
  348.       X2              =   3360
  349.       Y1              =   1320
  350.       Y2              =   1320
  351.    End
  352. End
  353. Option Explicit
  354. DefInt A-Z
  355. Dim LastY As Single
  356. Dim Active As String
  357. Dim LastDirection As String
  358. Dim tVal As Integer
  359.  
  360. ' Jeffrey M. Richter's Spin Button Control from Windows 3: A Developer's Guide
  361. ' Adapted for Visual Basic by Costas Kitsos with Mr. Richter's kind permission
  362.  
  363. ' Windows API functions used by the Spin Button Control
  364. Declare Function GetTickCount Lib "User" () As Long
  365. Declare Function GetAsyncKeyState Lib "User" (ByVal vKey As Integer) As Integer
  366.  
  367. Sub Command1_Click (Index As Integer)
  368. If Index = 0 Then
  369.   Time = tHour.Text + ":" + tMinute.Text + ":" + tSecond.Text + UCase$(tAMPM.Text)
  370.   Date = tMonth.Text + "/" + tDay.Text + "/" + tYear.Text
  371.   LastTime = 0
  372.   LastHour = Val(Format$(Time, "hh"))
  373.   LastQuarter = Val(Format$(Time, "nn")) \ 15
  374.   Unload SetTimeForm
  375. End If
  376. If Index = 1 Then
  377.   LastTime = 0
  378.   Unload SetTimeForm
  379. End If
  380.  
  381. End Sub
  382.  
  383. Sub Command3D1_Click ()
  384. AtomicTimeWasSet = False
  385. Atomic.Show 1
  386. Unload Atomic
  387. If AtomicTimeWasSet Then
  388.    Unload SetTimeForm
  389. End If
  390. End Sub
  391.  
  392. Sub FlipFlopTAMPM ()
  393.          If tAMPM.Text = "am" Then
  394.             tAMPM.Text = "pm"
  395.          Else
  396.             tAMPM.Text = "am"
  397.          End If
  398.  
  399. End Sub
  400.  
  401. Sub Form_GotFocus ()
  402.     tHour.SetFocus
  403.     DoEvents
  404.  
  405. End Sub
  406.  
  407. Sub Form_Load ()
  408. SetTimeForm.Left = Settings.Left + (Settings.Width / 2) - (SetTimeForm.Width / 2)
  409. SetTimeForm.Top = Settings.Top + (Settings.Height / 2) - (SetTimeForm.Height / 2)
  410. Dim Instant As Double
  411. Dim InitialHeight As Integer
  412.     InitialHeight = SpinButton(0).Height
  413.     SpinButton(0).Picture = N.Picture       'Set to the Normal Spin Button
  414.     SpinButton(0).Top = SpinButton(0).Top + (InitialHeight - SpinButton(0).Height) / 2
  415.     SpinButton(1).Picture = N.Picture       'Set to the Normal Spin Button
  416.     SpinButton(1).Top = SpinButton(1).Top + (InitialHeight - SpinButton(1).Height) / 2
  417.     Instant = Now
  418.     If Hour(Instant) = 0 Then
  419.        tHour.Text = "12"
  420.        tAMPM.Text = "am"
  421.     End If
  422.     If Hour(Instant) >= 1 And Hour(Instant) <= 11 Then
  423.        tHour.Text = Format$(Hour(Instant))
  424.        tAMPM.Text = "am"
  425.     End If
  426.     If Hour(Instant) = 12 Then
  427.        tHour.Text = Format$(Hour(Instant))
  428.        tAMPM.Text = "pm"
  429.     End If
  430.     If Hour(Instant) >= 13 And Hour(Instant) <= 23 Then
  431.        tHour.Text = Format$(Hour(Instant) - 12)
  432.        tAMPM.Text = "pm"
  433.     End If
  434.     tMinute.Text = Format$(Minute(Instant), "00")
  435.     tSecond.Text = Format$(Second(Instant), "00")
  436.     tMonth.Text = Format$(Month(Instant), "00")
  437.     tDay.Text = Format$(Day(Instant), "00")
  438.     tYear.Text = Format$(Year(Instant), "0000")
  439.     'SetTimeFOrm.Show
  440.     'DoEvents
  441.  
  442. End Sub
  443.  
  444. Sub MoveDown (c As Control)
  445. Dim CurVal As Integer
  446. CurVal% = Val(c.Text)
  447. Select Case c.Tag
  448.    Case "h"
  449.       If CurVal% = 12 Then
  450.          FlipFlopTAMPM
  451.       End If
  452.       If CurVal% = 1 Then
  453.          c.Text = "12"
  454.       Else
  455.          c.Text = Val(c.Text) - 1
  456.       End If
  457.    Case "m"
  458.       If CurVal% = 0 Then
  459.          c.Text = "59"
  460.       Else
  461.          c.Text = Format$(Val(c.Text) - 1, "00")
  462.       End If
  463.    Case "s"
  464.       If CurVal% = 0 Then
  465.          c.Text = "59"
  466.       Else
  467.          c.Text = Format$(Val(c.Text) - 1, "00")
  468.       End If
  469.    Case "a"
  470.       FlipFlopTAMPM
  471.    Case "n"
  472.       If CurVal% = 1 Then
  473.          c.Text = "12"
  474.       Else
  475.          c.Text = Format$(Val(c.Text) - 1, "00")
  476.       End If
  477.    Case "d"
  478.       If CurVal% = 1 Then
  479.          c.Text = "31"
  480.       Else
  481.          c.Text = Format$(Val(c.Text) - 1, "00")
  482.       End If
  483.    Case "y"
  484.       If CurVal% = 1 Then
  485.          c.Text = "2050"
  486.       Else
  487.          c.Text = Format$(Val(c.Text) - 1, "0000")
  488.       End If
  489. End Select
  490.  
  491. 'c.Text = Val(c.Text) - 1
  492. End Sub
  493.  
  494. Sub MoveUp (c As Control)
  495. Dim CurVal As Integer
  496. CurVal% = Val(c.Text)
  497. Select Case c.Tag
  498.    Case "h"
  499.       If CurVal% = 11 Then
  500.          FlipFlopTAMPM
  501.       End If
  502.       If CurVal% = 12 Then
  503.          c.Text = "1"
  504.       Else
  505.          c.Text = Val(c.Text) + 1
  506.       End If
  507.    Case "m"
  508.       If CurVal% = 59 Then
  509.          c.Text = "00"
  510.       Else
  511.          c.Text = Format$(Val(c.Text) + 1, "00")
  512.       End If
  513.    Case "s"
  514.       If CurVal% = 59 Then
  515.          c.Text = "00"
  516.       Else
  517.          c.Text = Format$(Val(c.Text) + 1, "00")
  518.       End If
  519.    Case "a"
  520.       FlipFlopTAMPM
  521.    Case "n"
  522.       If CurVal% = 12 Then
  523.          c.Text = "01"
  524.       Else
  525.          c.Text = Format$(Val(c.Text) + 1, "00")
  526.       End If
  527.    Case "d"
  528.       If CurVal% = 31 Then
  529.          c.Text = "01"
  530.       Else
  531.          c.Text = Format$(Val(c.Text) + 1, "00")
  532.       End If
  533.    Case "y"
  534.       If CurVal% = 2050 Then
  535.          c.Text = "1980"
  536.       Else
  537.          c.Text = Format$(Val(c.Text) + 1, "0000")
  538.       End If
  539.  
  540. End Select
  541.  
  542. End Sub
  543.  
  544. Sub SpinButton_DblClick (Index As Integer)
  545. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  546.    tMonth.SetFocus
  547. End If
  548. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  549.    tHour.SetFocus
  550. End If
  551. If LastDirection$ = "u" Then
  552.    Select Case Active$
  553.      Case "n"
  554.         Call MoveUp(tMonth)
  555.      Case "d"
  556.         Call MoveUp(tDay)
  557.      Case "y"
  558.         Call MoveUp(tYear)
  559.      Case "h"
  560.         Call MoveUp(tHour)
  561.      Case "m"
  562.         Call MoveUp(tMinute)
  563.      Case "s"
  564.         Call MoveUp(tSecond)
  565.      Case "a"
  566.         Call MoveUp(tAMPM)
  567.    End Select
  568. Else
  569.    Select Case Active$
  570.      Case "n"
  571.         Call MoveDown(tMonth)
  572.      Case "d"
  573.         Call MoveDown(tDay)
  574.      Case "y"
  575.         Call MoveDown(tYear)
  576.      Case "h"
  577.         Call MoveDown(tHour)
  578.      Case "m"
  579.         Call MoveDown(tMinute)
  580.      Case "s"
  581.         Call MoveDown(tSecond)
  582.      Case "a"
  583.         Call MoveDown(tAMPM)
  584.    End Select
  585. End If
  586. SpinButton(Index).SetFocus
  587. End Sub
  588.  
  589. Sub SpinButton_GotFocus (Index As Integer)
  590. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  591.    tMonth.SetFocus
  592.    Exit Sub
  593. End If
  594. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  595.    tHour.SetFocus
  596.    Exit Sub
  597. End If
  598.    Select Case Active$
  599.      Case "n"
  600.         tMonth.SetFocus
  601.      Case "d"
  602.         tDay.SetFocus
  603.      Case "y"
  604.         tYear.SetFocus
  605.      Case "h"
  606.         tHour.SetFocus
  607.      Case "m"
  608.         tMinute.SetFocus
  609.      Case "s"
  610.         tSecond.SetFocus
  611.      Case "a"
  612.         tAMPM.SetFocus
  613.    End Select
  614. End Sub
  615.  
  616. Sub SpinButton_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  617.  
  618. Const VK_LBUTTON = &H1
  619. Const TIME_DELAY = 180      ' Time delay between Spin Button Events
  620.  
  621. Dim dwEvent As Long
  622. LastY = Y
  623. ' Make sure that the Spin Button Event occurs at least once
  624. dwEvent = GetTickCount() - TIME_DELAY
  625.  
  626. SpinIt:
  627.  
  628.    ' Do this while the user holds down the left mouse button
  629.    Do While (GetAsyncKeyState(VK_LBUTTON) And &H8000) = -32768
  630.  
  631.         ' Break out of the loop if we haven't waited long enough
  632.         If dwEvent + TIME_DELAY > GetTickCount() Then GoTo Break:
  633.  
  634.         ' If the user wants to increment the counter
  635.         If Y > (SpinButton(Index).Height \ 2) Then
  636.             SpinButton(Index).Picture = d.Picture  ' Set Picture to Up
  637.             If Index = 1 Then
  638.             Select Case Active$
  639.                Case "n"
  640.                    Call MoveDown(tMonth)
  641.                Case "d"
  642.                    Call MoveDown(tDay)
  643.                Case "y"
  644.                    Call MoveDown(tYear)
  645.             End Select
  646.             End If
  647.             If Index = 0 Then
  648.             Select Case Active$
  649.                Case "h"
  650.                    Call MoveDown(tHour)
  651.                Case "s"
  652.                    Call MoveDown(tSecond)
  653.                Case "m"
  654.                    Call MoveDown(tMinute)
  655.                Case "a"
  656.                    Call MoveDown(tAMPM)
  657.             End Select
  658.             End If
  659.             LastDirection$ = "d"
  660.         End If
  661.  
  662.         ' If the user wants to decrement the counter
  663.         If Y < (SpinButton(Index).Height \ 2) Then
  664.             SpinButton(Index).Picture = u.Picture   ' Set Picture to Down
  665.             If Index = 1 Then
  666.             Select Case Active$
  667.                Case "n"
  668.                    Call MoveUp(tMonth)
  669.                Case "d"
  670.                    Call MoveUp(tDay)
  671.                Case "y"
  672.                    Call MoveUp(tYear)
  673.             End Select
  674.             End If
  675.             If Index = 0 Then
  676.             Select Case Active$
  677.                Case "h"
  678.                    Call MoveUp(tHour)
  679.                Case "s"
  680.                    Call MoveUp(tSecond)
  681.                Case "m"
  682.                    Call MoveUp(tMinute)
  683.                Case "a"
  684.                    Call MoveUp(tAMPM)
  685.             End Select
  686.             End If
  687.             LastDirection$ = "u"
  688.         End If
  689.  
  690.         ' Save the last time the Spin Button was active
  691.         dwEvent = GetTickCount()
  692.     Loop
  693.     
  694.     ' Set the Picture to Normal
  695.     SpinButton(Index).Picture = N.Picture
  696.     If Index = 1 Then
  697.     Select Case Active$
  698.        Case "n"
  699.           tMonth.SetFocus
  700.        Case "d"
  701.           tDay.SetFocus
  702.        Case "y"
  703.           tYear.SetFocus
  704.     End Select
  705.     End If
  706.     If Index = 0 Then
  707.     Select Case Active$
  708.        Case "h"
  709.           tHour.SetFocus
  710.        Case "m"
  711.           tMinute.SetFocus
  712.        Case "s"
  713.           tSecond.SetFocus
  714.        Case "a"
  715.           tAMPM.SetFocus
  716.     End Select
  717.     End If
  718.     DoEvents
  719.     
  720.     Exit Sub
  721.  
  722. Break:
  723.     GoTo SpinIt:
  724.  
  725. End Sub
  726.  
  727. Sub tAMPM_GotFocus ()
  728. tAMPM.SelStart = 0
  729. tAMPM.SelLength = 2
  730. Active$ = "a"
  731.  
  732. End Sub
  733.  
  734. Sub tAMPM_KeyPress (KeyAscii As Integer)
  735. If KeyAscii >= 32 Then
  736.    FlipFlopTAMPM
  737.    KeyAscii = 0
  738.    tAMPM.SelStart = 0
  739.    tAMPM.SelLength = 2
  740. End If
  741. End Sub
  742.  
  743. Sub tAMPM_LostFocus ()
  744. If tAMPM.Text <> "am" And tAMPM.Text <> "pm" Then
  745.    tAMPM.Text = "am"
  746. End If
  747.  
  748. End Sub
  749.  
  750. Sub tDay_GotFocus ()
  751. tDay.SelStart = 0
  752. tDay.SelLength = 2
  753. Active$ = "d"
  754. End Sub
  755.  
  756. Sub tDay_KeyPress (KeyAscii As Integer)
  757. If KeyAscii >= 32 Then
  758.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  759. End If
  760.  
  761. End Sub
  762.  
  763. Sub tDay_LostFocus ()
  764. tVal = Val(tDay.Text)
  765. If tVal < 1 Or tVal > 31 Then
  766.    tVal = 1
  767. End If
  768. tDay.Text = Format$(tVal, "00")
  769. End Sub
  770.  
  771. Sub tHour_GotFocus ()
  772. tHour.SelStart = 0
  773. tHour.SelLength = 2
  774. Active$ = "h"
  775. End Sub
  776.  
  777. Sub tHour_KeyPress (KeyAscii As Integer)
  778. If KeyAscii >= 32 Then
  779.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  780. End If
  781.  
  782. End Sub
  783.  
  784. Sub tHour_LostFocus ()
  785. tVal = Val(tHour.Text)
  786. If tVal < 1 Or tVal > 12 Then
  787.    tVal = 12
  788. End If
  789. tHour.Text = Format$(tVal, "0")
  790. End Sub
  791.  
  792. Sub tMinute_GotFocus ()
  793. tMinute.SelStart = 0
  794. tMinute.SelLength = 2
  795. Active$ = "m"
  796. End Sub
  797.  
  798. Sub tMinute_KeyPress (KeyAscii As Integer)
  799. If KeyAscii >= 32 Then
  800.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  801. End If
  802.  
  803. End Sub
  804.  
  805. Sub tMinute_LostFocus ()
  806. tVal = Val(tMinute.Text)
  807. If tVal <= 0 Or tVal > 59 Then
  808.    tVal = 0
  809. End If
  810. tMinute.Text = Format$(tVal, "00")
  811. End Sub
  812.  
  813. Sub tMonth_GotFocus ()
  814. tMonth.SelStart = 0
  815. tMonth.SelLength = 2
  816. Active$ = "n"
  817. End Sub
  818.  
  819. Sub tMonth_KeyPress (KeyAscii As Integer)
  820. If KeyAscii >= 32 Then
  821.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  822. End If
  823. End Sub
  824.  
  825. Sub tMonth_LostFocus ()
  826. tVal = Val(tMonth.Text)
  827. If tVal < 1 Or tVal > 12 Then
  828.    tVal = 12
  829. End If
  830. tMonth.Text = Format$(tVal, "00")
  831. End Sub
  832.  
  833. Sub tSecond_GotFocus ()
  834. tSecond.SelStart = 0
  835. tSecond.SelLength = 2
  836. Active$ = "s"
  837. End Sub
  838.  
  839. Sub tSecond_KeyPress (KeyAscii As Integer)
  840. If KeyAscii >= 32 Then
  841.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  842. End If
  843. End Sub
  844.  
  845. Sub tSecond_LostFocus ()
  846. tVal = Val(tSecond.Text)
  847. If tVal <= 0 Or tVal > 59 Then
  848.    tVal = 0
  849. End If
  850. tSecond.Text = Format$(tVal, "00")
  851. End Sub
  852.  
  853. Sub tYear_GotFocus ()
  854. tYear.SelStart = 0
  855. tYear.SelLength = 4
  856. Active$ = "y"
  857. End Sub
  858.  
  859. Sub tYear_KeyPress (KeyAscii As Integer)
  860. If KeyAscii >= 32 Then
  861.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  862. End If
  863.  
  864. End Sub
  865.  
  866. Sub tYear_LostFocus ()
  867. tVal = Val(tYear.Text)
  868. If tVal < 100 Then tVal = tVal + 1900
  869. If tVal < 1980 Or tVal > 2050 Then
  870.    tVal = 1980
  871. End If
  872. tYear.Text = Format$(tVal, "0000")
  873. End Sub
  874.  
  875.